home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet internetowy / Przegladarki internetowe / Mozilla Seamonkey 1.0.5 pl / seamonkey-1.0.5.pl-PL.win32.installer.exe / BROWSER.XPI / bin / chrome / help.jar / content / help / contextHelp.js < prev    next >
Encoding:
Text File  |  2004-04-18  |  4.1 KB  |  99 lines

  1. /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  * ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is Mozilla Communicator client code, released
  16.  * March 31, 1998.
  17.  *
  18.  * The Initial Developer of the Original Code is
  19.  * Netscape Communications Corporation.
  20.  * Portions created by the Initial Developer are Copyright (C) 1998-1999
  21.  * the Initial Developer. All Rights Reserved.
  22.  *
  23.  * Contributor(s):
  24.  *   R.J. Keller <rlk@trfenv.com>
  25.  *
  26.  * Alternatively, the contents of this file may be used under the terms of
  27.  * either the GNU General Public License Version 2 or later (the "GPL"), or
  28.  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  29.  * in which case the provisions of the GPL or the LGPL are applicable instead
  30.  * of those above. If you wish to allow use of your version of this file only
  31.  * under the terms of either the GPL or the LGPL, and not to allow others to
  32.  * use your version of this file under the terms of the MPL, indicate your
  33.  * decision by deleting the provisions above and replace them with the notice
  34.  * and other provisions required by the GPL or the LGPL. If you do not delete
  35.  * the provisions above, a recipient may use your version of this file under
  36.  * the terms of any one of the MPL, the GPL or the LGPL.
  37.  *
  38.  * ***** END LICENSE BLOCK ***** */
  39.  
  40. const MOZILLA_CONTENT_PACK = "chrome://help/locale/mozillahelp.rdf";
  41. //Set the default content pack to the Mozilla content pack. Use the
  42. //setHelpFileURI function to set this value.
  43. var helpFileURI = MOZILLA_CONTENT_PACK;
  44.  
  45. // openHelp - Opens up the Mozilla Help Viewer with the specified
  46. //    topic and content pack.
  47. // see http://www.mozilla.org/projects/help-viewer/content_packs.html
  48. function openHelp(topic, contentPack)
  49. {
  50.   //cp is the content pack to use in this function. If the contentPack
  51.   //parameter was set, we will use that content pack. If not, we will
  52.   //use the default content pack set by setHelpFileURI().
  53.   var cp = contentPack || helpFileURI;
  54.  
  55.   // Try to find previously opened help.
  56.   var topWindow = locateHelpWindow(cp);
  57.  
  58.   if ( topWindow ) {
  59.     // Open topic in existing window.
  60.     topWindow.focus();
  61.     topWindow.displayTopic(topic);
  62.   } else {
  63.     // Open topic in new window.
  64.     const params = Components.classes["@mozilla.org/embedcomp/dialogparam;1"]
  65.                              .createInstance(Components.interfaces.nsIDialogParamBlock);
  66.     params.SetNumberStrings(2);
  67.     params.SetString(0, cp);
  68.     params.SetString(1, topic);
  69.     const ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
  70.                          .getService(Components.interfaces.nsIWindowWatcher);
  71.     ww.openWindow(null, "chrome://help/content/help.xul", "_blank", "chrome,all,alwaysRaised,dialog=no", params);
  72.   }
  73. }
  74.  
  75. //setHelpFileURI - Sets the default content pack to use in the Help Viewer
  76. function setHelpFileURI(rdfURI) {
  77.   helpFileURI = rdfURI; 
  78. }
  79.  
  80. // Locate mozilla:help window (if any) opened for this help file uri.
  81. function locateHelpWindow(helpFileURI) {
  82.   const windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1']
  83.                                   .getService(Components.interfaces.nsIWindowMediator);
  84.   var iterator = windowManager.getEnumerator("mozilla:help");
  85.   var topWindow = null;
  86.   var currentWindow;
  87.  
  88.   // Loop through the help windows looking for one with the
  89.   // current Help Content Pack loaded.
  90.   while (iterator.hasMoreElements()) {
  91.     currentWindow = iterator.getNext();
  92.     if (currentWindow.getHelpFileURI() == helpFileURI) {
  93.       topWindow = currentWindow;
  94.       break;  
  95.     }  
  96.   }
  97.   return topWindow;
  98. }
  99.